///===============================================
///=  THIS FILE CODES VARIABLES FOR THE 2006-10  =
///=  ISSUES, PID, BELIEF, & BEHAVIOR VARIABLES. =
///=  I THEN RUN ALL OF THE MODELS AND FIGURES.  = 
///=  DATA CLEANED ON 7/05/16 BY PAUL GOREN.     = 
///===============================================
version 13.1
use "c:\GSS\081012gss.dta", clear

/// cases for 2008-2012 = 1295 (see panstat_3)
/// 0 cases missing 2008
/// 728 cases missing 2012


/// ============================
/// = CODING OF ALL VARIABLES  =
/// ============================
gen wt123= wtpannr123
fre wt123

/// pid 2008
fre partyid_1
clonevar pid08=partyid_1
replace pid08=3 if partyid_1==7
replace pid08=pid08/6
label define pid 0 "strd dem" 1 "strg rep" .n "no answer" .i "not in 12"
label value pid08 pid 
fre pid08

/// pid 2012
fre partyid_3
clonevar pid12=partyid_3
replace pid12=3 if partyid_3==7
replace pid12=pid12/6
replace pid12=.i if panstat_3!=1
label value pid12 pid 
fre pid12


/// relcom 2008
fre pray_1 
gen pray08=1-(pray_1-1)/5
label define pray 0 "never" 1 "several times day" .i "not in 12"
label variable pray08 "how often pray"
label value pray08 pray
fre pray08

fre attend_1
recode attend_1 9=. 
gen attend08=(attend_1/8)
label define attend 0 "never" 1 "several times week" .i "not in 12"
label variable attend08 "how often attend church"
label value attend08 attend
fre attend08

fre relactiv_1
gen relact08=(relactiv_1-1)/9
label define relact 0 "never" 1 "several times week" .i "not in 12"
label variable relact08 "how much rel actv"
label value relact08 relact
fre relact08

fre god_1
gen god08=(god_1-1)/5
label define god 0 "don't believe" 1 "know HE exists" .i "not in 12"
label variable god08 "how conf god exists?"
label value god08 god
fre god08

/// polychoric pray08 attend08 relact08 god08
display (4*.558)/(1+.558*3)
egen relcom08miss=rowmiss(pray08 attend08 relact08 god08)
egen relcom08=rowmean(pray08 attend08 relact08 god08) if relcom08miss<2
label variable relcom08 "rel commitment index"
label define relcom 0 "very weak" 1 "very strong" .i "not in 12"
label value relcom08 relcom
fre relcom08miss relcom08

/// relcom 2012
fre pray_3
gen pray12=1-(pray_3-1)/5
replace pray12=.i if panstat_3!=1
label variable pray12 "how often pray"
label value pray12 pray
fre pray12

fre attend_3
gen attend12=(attend_3/8)
replace attend12=.i if panstat_3!=1
label variable attend12 "how often attend church"
label value attend12 attend
fre attend12

fre relactiv_3
gen relact12=(relactiv_3-1)/9
replace relact12=.i if panstat_3!=1
label variable relact12 "how much rel actv"
label value relact12 relact
fre relact12

fre god_3
gen god12=(god_3-1)/5
replace god12=.i if panstat_3!=1
label variable god12 "how conf god exists?"
label value god12 god
fre god12

///polychoric pray12 attend12 relact12 god12
display (4*.576)/(1+.576*3)
egen relcom12miss=rowmiss(pray12 attend12 relact12 god12)
egen relcom12=rowmean(pray12 attend12 relact12 god12) if relcom12miss<2
replace relcom12=.i if panstat_3!=1
label variable relcom12 "rel commitment index"
label value relcom12 relcom
fre relcom12miss relcom12


/// orthodox 2008
fre bible_1 
gen orthodox08=bible_1 
recode orthodox08 1=1 2/8=0 
label define orthodox 1 "yes" 0 "no" .i "not in 12"
label variable orthodox08 "Bible literal"
label value orthodox08 orthodox
fre orthodox08

/// orthodox 2012
fre bible_3 
gen orthodox12=bible_3 
recode orthodox12 1=1 2/8=0 0=.
replace orthodox12=.i if panstat_3!=1
label variable orthodox12 "Bible literal"
label value orthodox12 orthodox
fre orthodox12


/// moralissues abortion 2006
/// ballot var shows items not on ballot b
fre ballot
tab ballot abany_1, miss
fre abany_1
gen abort1_08=abany_1
recode abort1_08 1=0 2=1 
replace abort1_08=.b if ballot==2 
label variable abort1_08 "abort any reason?"
label define abort 0 "yes" 1 "no" .b "not on ballot b" .i "not in 12"
label value abort1_08 abort
fre abort1_08

fre abdefect_1
gen abort2_08=abdefect_1
recode abort2_08 1=0 2=1
replace abort2_08=.b if ballot==2 
label variable abort2_08 "abort b defect?"
label value abort2_08 abort
fre abort2_08

fre abhlth_1
gen abort3_08=abhlth_1
recode abort3_08 1=0 2=1 
replace abort3_08=.b if ballot==2  
label variable abort3_08 "abort health?"
label value abort3_08 abort
fre abort3_08

fre abnomore_1
gen abort4_08=abnomore_1
recode abort4_08 1=0 2=1 
replace abort4_08=.b if ballot==2 
label variable abort4_08 "abort no more kids?"
label value abort4_08 abort
fre abort4_08

fre abpoor_1
gen abort5_08=abpoor_1
recode abort5_08 1=0 2=1 
replace abort5_08=.b if ballot==2  
label variable abort5_08 "abort b/c too poor?"
label value abort5_08 abort
fre abort5_08

fre abrape_1
gen abort6_08=abrape_1
recode abort6_08 1=0 2=1 
replace abort6_08=.b if ballot==2 
label variable abort6_08 "abort rape?"
label value abort6_08 abort
fre abort6_08

fre absingle_1
gen abort7_08=absingle_1
recode abort7_08 1=0 2=1  
replace abort7_08=.b if ballot==2 
label variable abort7_08 "abort single??"
label value abort7_08 abort
fre abort7_08

alpha abort1_08 abort2_08 abort3_08 abort4_08 abort5_08 abort6_08 abort7_08, item std
egen abortion08miss=rowmiss(abort1_08 abort2_08 abort3_08 abort4_08 abort5_08 abort6_08 abort7_08)
egen abortion08=rowmean(abort1_08 abort2_08 abort3_08 abort4_08 abort5_08 abort6_08 abort7_08) if abortion08miss<4
replace abortion08=.b if ballot==2
label variable abortion08 "abortion index"
label define abortion 0 "pro-choice" 1 "pro-life" .b "not on ballot b" .i "not in 12"
label value abortion08 abortion
fre abortion08miss abortion08

/// gayrights 2008
fre homosex_1
gen homosex1_08=homosex_1
recode homosex1_08 1=1 2=.666 3=.333 4=0 
replace homosex1_08=.b if ballot==2 
label variable homosex1_08 "homosex rels wrong?"
label define wrong 0 "not wrong at all" 1 "always wrong" .b "not on ballot b" .i "not in 12"
label value homosex1_08 wrong
fre homosex1_08

fre marhomo_1
gen homosex2_08=marhomo_1
recode homosex2_08 1=0 2=.25 3=.5 4=.75 5=1
replace homosex2_08=.b if ballot==2 
label variable homosex2_08 "homosex have right to marry"
label define disagree 0 "strg agree" 1 "strg disagree" .b "not on ballot b" .i "not in 12"
label value homosex2_08 disagree
fre homosex2_08

polychoric homosex1_08 homosex2_08
display (2*.804)/(1+.804*1)
gen homosex08=(homosex1_08+homosex2_08)/2
replace homosex08=.b if ballot==2 
label variable homosex08 "supp gay rights"
label define support 0 "support" 1 "oppose" .b "not on ballot b" .i "not in 12"
label value homosex08 support
fre homosex08

/// polychoric homosex1_08 homosex2_08  abort1_08 abort2_08 abort3_08 abort4_08 abort5_08 abort6_08 abort7_08
display (9*.726)/(1+.726*8)
gen moralissues08=(abortion08+homosex08)/2
label variable moralissues08 "moralissues index"
label define moralissues 0 "liberal" 1 "cons" .b "not on ballot b" .i "not in 12"
replace moralissues08=.b if ballot==2
label value moralissues08 moralissues
fre moralissues08


/// abortion 2012
fre abany_3
gen abort1_12=abany_3
recode abort1_12 1=0 2=1 
replace abort1_12=.i if panstat_3!=1
replace abort1_12=.b if ballot==2 
label variable abort1_12 "abort any reason?"
label value abort1_12 abort
fre abort1_12

fre abdefect_3
gen abort2_12=abdefect_3
recode abort2_12 1=0 2=1
replace abort2_12=.i if panstat_3!=1
replace abort2_12=.b if ballot==2 
label variable abort2_12 "abort b defect?"
label value abort2_12 abort
fre abort2_12

fre abhlth_3
gen abort3_12=abhlth_3
replace abort3_12=.i if panstat_3!=1
replace abort3_12=.b if ballot==2 
recode abort3_12 1=0 2=1  
label variable abort3_12 "abort health?"
label value abort3_12 abort
fre abort3_12

fre abnomore_3
gen abort4_12=abnomore_3
replace abort4_12=.i if panstat_3!=1
replace abort4_12=.b if ballot==2 
recode abort4_12 1=0 2=1 
label variable abort4_12 "abort no more kids?"
label value abort4_12 abort
fre abort4_12

fre abpoor_3
gen abort5_12=abpoor_3
replace abort5_12=.i if panstat_3!=1
replace abort5_12=.b if ballot==2 
recode abort5_12 1=0 2=1  
label variable abort5_12 "abort b/c too poor?"
label value abort5_12 abort
fre abort5_12

fre abrape_3
gen abort6_12=abrape_3
recode abort6_12 1=0 2=1 
replace abort6_12=.i if panstat_3!=1 
replace abort6_12=.b if ballot==2 
label variable abort6_12 "abort rape?"
label value abort6_12 abort
fre abort6_12

fre absingle_3
gen abort7_12=absingle_3
recode abort7_12 1=0 2=1  
replace abort7_12=.i if panstat_3!=1
replace abort7_12=.b if ballot==2 
label variable abort7_12 "abort single??"
label value abort7_12 abort
fre abort7_12

alpha abort1_12 abort2_12 abort3_12 abort4_12 abort5_12 abort6_12 abort7_12, item std
egen abortion12miss=rowmiss(abort1_12 abort2_12 abort3_12 abort4_12 abort5_12 abort6_12 abort7_12)
egen abortion12=rowmean(abort1_12 abort2_12 abort3_12 abort4_12 abort5_12 abort6_12 abort7_12) if abortion12miss<4
replace abortion12=.i if panstat_3!=1
replace abortion12=.b if ballot==2 
label variable abortion12 "abortion index"
label value abortion12 abortion
fre abortion12miss abortion12

/// gay rights 2012
fre homosex_3
gen homosex1_12=homosex_3
recode homosex1_12 1=1 2=.666 3=.333 4=0 
replace homosex1_12=.i if panstat_3!=1
replace homosex1_12=.b if ballot==2 
label variable homosex1_12 "homosex rels wrong?"
label value homosex1_12 wrong
fre homosex1_12

fre marhomo_3
gen homosex2_12=marhomo_3
recode homosex2_12 1=0 2=.25 3=.5 4=.75 5=1
replace homosex2_12=.i if panstat_3!=1
replace homosex2_12=.b if ballot==2 
label variable homosex2_12 "homosex have right to marry"
label value homosex2_12 disagree
fre homosex2_12

polychoric homosex1_12 homosex2_12
display (2*.811)/(1+.811*1)
gen homosex12=(homosex1_12+homosex2_12)/2
replace homosex12=.i if panstat_3!=1
replace homosex12=.b if ballot==2 
label variable homosex12 "supp gay rights"
label value homosex12 support
fre homosex12

/// polychoric homosex1_12 homosex2_12  abort1_12 abort2_12 abort3_12 abort4_12 abort5_12 abort6_12 abort7_12
display (9*.752)/(1+.752*8)
gen moralissues12=(abortion12+homosex12)/2
label variable moralissues12 "moralissues index"
replace moralissues12=.i if homosex12==.i
replace moralissues12=.b if ballot==2 
label value moralissues12 moralissues
fre moralissues12


/// controls
/// black
fre race_1
gen black=race_1
recode black 1=0 2=1 3=0  
label variable black "black dummy"
label define black 1 "black" 0 "non-black" 
label value black black
fre black

/// age
fre age_1
gen age=age_1
replace age=. if age_1==99
fre age

/// female
fre sex_1
gen female=sex_1
recode female 1=0 2=1
fre female

/// college
fre degree_1
gen college=degree_1
recode college 0/2=0 3/4=1 
label variable college "college grad?"
label define yes 0 "no" 1 "yes" 
label value college yes
fre college


/// ===================================
/// = TABLE 1: STABILITY ESTIMATES.   =  
/// ===================================
svyset [pw=wt123]
regress moralissues12 moralissues08 [pw=wt123], cformat(%4.2f) beta
regress pid12 pid08 [pw=wt123], cformat(%4.2f) beta
regress orthodox12 orthodox08 [pw=wt123], cformat(%4.2f) beta
regress relcom12 relcom08 [pw=wt123], cformat(%4.2f)  beta


/// ======================================================
/// = FIGURE 1 & TABLE D: DV = PID12, IV = MORALISSUES08 =  
/// ====================================================== 
svy: regress pid12 moralissues08 pid08 orthodox08 relcom08 age female black college, cformat(%4.2f)  
margins, at(moralissues08=(0(.1)1) orthodox08=1 female=1 black=0 college=0)
marginsplot, ///
  name(pid0812, replace) ///
  plotopts(mcolor(black)) ciopts(lcolor(black)) ///
  title("", margin(tiny)) ///
  title(2008-12 GSS, size(large) ring(0)) ///
  xsize(5) ///
  xtitle("2008 Culture War Position", size(medlarge) margin(zero)) ///
  xlabel(0 "Progressive" .99 "Orthodox", noticks labsize(medium)) ///
  ysize(5) ///
  ytitle("2012 Party ID", size(medlarge) margin(zero)) ///
  ylabel(0 "Strg Dem" .50 "Indp" 1 "Strg Rep", noticks labsize(medium) angle(0)) ///
  yline(.50, lpattern(shortdash))  ///
  text(.11 .95 "b = 0.08", size(medium)) ///
  text(.04 .95 "{it:t} = 2.22", size(medium)) ///
  scheme(s1mono) ///
  scale(.5) aspectratio(1) ///
  plotregion(lcolor(white))  

graph save pid0812 "C:\Graphs\pid0812.gph", replace  

/// ======================================================
/// = FIGURE 2 & TABLE D: DV = MORALISSUES12, IV = PID08 =  
/// ====================================================== 
svy: regress moralissues12 moralissues08 pid08 orthodox08 relcom08 age female black college, cformat(%4.2f)  
margins, at(pid08=(0(.1)1) orthodox08=1 female=1 black=0 college=0)
marginsplot, ///
  name(cw0812p, replace) ///
  plotopts(mcolor(black)) ciopts(lcolor(black)) ///
  title(2008-12 GSS, size(large) ring(0)) ///
  xsize(5) ///
  xtitle("2008 Party ID", size(medlarge) margin(zero)) ///
  xlabel(0 "Strg Dem" .98 "Strg Rep", noticks labsize(medium)) ///
  ysize(5) ///
  ytitle("2012 Culture War Position", size(medlarge) margin(zero)) ///
  ylabel(0 "Prog" 1 "Ortho", noticks labsize(medium) angle(0)) ///
  yline(.50, lpattern(shortdash))  ///
  text(.11 .95 "b = 0.05", size(medium)) ///
  text(.04 .95 "{it:t} = 2.18", size(medium)) ///
  scheme(s1mono) ///
  scale(.5) aspectratio(1) ///
  plotregion(lcolor(white))  

graph save cw0812p "C:\Graphs\cw0812p.gph", replace  


/// ===========================================================
/// = FIGURE 3 & TABLE D: DV = ORTHODOX12, IV = MORALISSUES08 =  
/// =========================================================== 
svy: logit orthodox12 moralissues08 pid08 orthodox08 relcom08 age female black college, cformat(%4.2f)  
margins, at(moralissues08=(0(.1)1) orthodox08=1 female=1 black=0 college=0)
marginsplot, ///
  name(ortho0812, replace) ///
  plotopts(mcolor(black)) ciopts(lcolor(black)) ///
  title(2008-12 GSS, size(large) ring(0)) ///
  xsize(5) ///
  xtitle("2008 Culture War Position", size(medlarge) margin(zero)) ///
  xlabel(0 "Progressive" .99 "Orthodox", noticks labsize(medium)) ///
  ysize(5) ///
  ytitle("2012 Bible Word of God?", size(medlarge) margin(zero)) ///
  ylabel(0 "P(no)" 1 "P(yes)", noticks labsize(medium) angle(0)) ///
  yline(.50, lpattern(shortdash))  ///
  text(.11 .95 "b = 1.65", size(medium)) ///
  text(.04 .95 "{it:t} = 3.23", size(medium)) ///
  scheme(s1mono) ///
  scale(.5) aspectratio(1) ///
  plotregion(lcolor(white))  

graph save ortho0812 "C:\Graphs\ortho0812.gph", replace  
 
  
/// ============================================================
/// = FIGURE 4 & TABLE D: DV = MORALISSUES12, IV = ORTHODOX08  =  
/// ============================================================ 
svy: regress moralissues12 moralissues08 pid08 orthodox08 relcom08 age female black college, cformat(%4.2f)  
margins, at(orthodox08=(0(1)1) female=1 black=0 college=0)
marginsplot, ///
  name(cw0812o, replace) ///
  plotopts(mcolor(black)) ciopts(lcolor(black)) ///
  title(2008-12 GSS, size(large) ring(0)) ///
  xsize(5) ///
  xtitle("2008 Bible Word of God?", size(medlarge) margin(zero)) ///
  xlabel(0 "No" .98 "Yes", noticks labsize(medium)) ///
  ysize(5) ///
  ytitle("2012 Culture War Position", size(medlarge) margin(zero)) ///
  ylabel(0 "Prog" 1 "Ortho", noticks labsize(medium) angle(0)) ///
  yline(.50, lpattern(shortdash))  /// 
  text(.11 .95 "b = 0.09", size(medium)) ///
  text(.04 .95 "{it:t} = 3.54", size(medium)) ///
  scheme(s1mono) ///
  scale(.5) aspectratio(1) ///
  plotregion(lcolor(white))  

graph save cw0812o "C:\Graphs\cw0812o.gph", replace    

    
/// =========================================================
/// = FIGURE 5 & TABLE D: DV = RELCOM12, IV = MORALISSUES08 =  
/// ========================================================= 
svy: regress relcom12 moralissues08 pid08 orthodox08 relcom08 age female black college, cformat(%4.2f)  
margins, at(moralissues08=(0(.1)1) orthodox08=1 female=1 black=0 college=0)
marginsplot, ///
  name(relcom0812, replace) ///
  plotopts(mcolor(black)) ciopts(lcolor(black)) ///
  title(2008-12 GSS, size(large) ring(0)) ///
  xsize(5) ///
  xtitle("2008 Culture War Position", size(medlarge) margin(zero)) ///
  xlabel(0 "Progressive" .99 "Orthodox", noticks labsize(medium)) ///
  ysize(5) ///
  ytitle("2012 Religious Commitment", size(medlarge) margin(zero)) ///
  ylabel(0 "Weak" 1 "Strong", noticks labsize(medium) angle(0)) ///
  yline(.50, lpattern(shortdash))  ///
  text(.11 .95 "b = 0.04", size(medium)) ///
  text(.04 .95 "{it:t} = 1.59", size(medium)) ///
  scheme(s1mono) ///
  scale(.5) aspectratio(1) ///
  plotregion(lcolor(white))  

graph save relcom0812 "C:\Graphs\relcom0812.gph", replace    


/// ==========================================================
/// = FIGURE 6 & TABLE D: DV = MORALISSUES12, IV = RELCOM08  =  
/// ==========================================================   
svy: regress moralissues12 moralissues08 pid08 orthodox08 relcom08 age female black college, cformat(%4.2f)  
margins, at(relcom08=(0(.1)1) orthodox08=1 female=1 black=0 college=0)
marginsplot, ///
  name(cw0812r, replace) ///
  plotopts(mcolor(black)) ciopts(lcolor(black)) ///
  title(2008-12 GSS, size(large) ring(0)) ///
  xsize(5) /// 
  xtitle("2008 Religious Commitment", size(medlarge) margin(zero)) ///
  xlabel(0 "Weak" .98 "Strong", noticks labsize(medium)) ///
  ysize(5) ///
  ytitle("2012 Culture War Position", size(medlarge) margin(zero)) ///
  ylabel(0 "Prog" 1 "Ortho", noticks labsize(medium) angle(0)) ///
  yline(.50, lpattern(shortdash))  ///
  text(.11 .95 "b = 0.07", size(medium)) ///
  text(.04 .95 "{it:t} = 1.70", size(medium)) ///
  scheme(s1mono) ///
  scale(.5) aspectratio(1) ///
  plotregion(lcolor(white))  

graph save cw0812r "C:\Graphs\cw0812r.gph", replace    

  
/// ==============================================
/// = SUPPLEMENTAL MATERIALS: ON-LINE APPENDICES =  
/// ==============================================

/// =====================================================
/// = TABLE A: DESCRIPTIVE STATISTICS FOR KEY VARIABLES =  
/// =====================================================
summ moralissues08 pid08 orthodox08 relcom08
summ moralissues12 pid12 orthodox12 relcom12


/// =============================
/// = FIGURE A: Kernal Desnity  =  
/// =============================    
twoway(kdensity moralissues08, lcolor(red) lwidth(medium) kernel(gaussian) bwidth(.075)) /// 
 (kdensity moralissues12, lcolor(blue) lwidth(medium) kernel(gaussian) bwidth(.075) ), ///
 name(cw0812density, replace) ///
 title("2008-12 GSS", size(medsmall) ring(0)) ///
 ytitle("Density", size(medsmall) margin(zero)) ///
 ylabel(.00 " " 1.5 " ", labsize(small) angle(zero) tstyle(major_notick)) ///
 xlabel(0 "Progressive" .97 "Orthodox", labsize(small) tstyle(major_notick)) ///
 xtitle("Position on Culture War Issues", size(medsmall) margin(zero)) ///
 legend(on order(1 "2008" 2 "2012") cols(2) ring(0)) ///
 plotregion(lcolor(white)) ///
 scheme(s1mono)

graph save cw0812density "C:\Graphs\cw0812density.gph", replace


/// ================================================================
/// = TABLE H ROBUSTNESS CHECK: ABORTION & GAY RIGHTS ON PARTY ID  =  
/// ================================================================
/// 2 items used to measure gay rights
/// 7 item used to measure abortion 

svy: regress pid12 moralissues08 pid08 orthodox08 relcom08 age female black college, cformat(%4.2f) 
svy: regress pid12 abortion08 pid08 orthodox08 relcom08 age female black college, cformat(%4.2f)  
svy: regress pid12 homosex08 pid08 orthodox08 relcom08 age female black college, cformat(%4.2f) 
svy: regress pid12 abortion08 homosex08 pid08 orthodox08 relcom08 age female black college, cformat(%4.2f)


/// ===============================================================
/// = TABLE I ROBUSTNESS CHECK: ABORTION & GAY RIGHTS ON ORTHODOX =  
/// ===============================================================
svy: logit orthodox12 moralissues08 pid08 orthodox08 relcom08 age female black college, cformat(%4.2f) 
svy: logit orthodox12 abortion08 pid08 orthodox08 relcom08 age female black college, cformat(%4.2f)  
svy: logit orthodox12 homosex08 pid08 orthodox08 relcom08 age female black college, cformat(%4.2f) 
svy: logit orthodox12 abortion08 homosex08 pid08 orthodox08 relcom08 age female black college, cformat(%4.2f)


/// =============================================================
/// = TABLE J ROBUSTNESS CHECK: ABORTION & GAY RIGHTS ON RELCOM =  
/// =============================================================
svy: regress relcom12 moralissues08 pid08 orthodox08 relcom08 age female black college, cformat(%4.2f) 
svy: regress relcom12 abortion08 pid08 orthodox08 relcom08 age female black college, cformat(%4.2f)  
svy: regress relcom12 homosex08 pid08 orthodox08 relcom08 age female black college, cformat(%4.2f) 
svy: regress relcom12 abortion08 homosex08 pid08 orthodox08 relcom08 age female black college, cformat(%4.2f)


/// ============================================================
/// = TABLE M ROBUSTNESS CHECK: SYMBOLIC IDEOLOGY ON ALL 4 DVS =  
/// ============================================================
/// ideo: based on 7-pt scale 
fre polviews_1
gen ideo08=polviews_1
replace ideo08=(ideo08-1)/6
label variable ideo08 "Ideo ID"
label define ideo08 0 "ext lib" 1 "ext con"
label value ideo08 ideo08
fre ideo08

svy: regress moralissues12 moralissues08 pid08 orthodox08 relcom08 age female black college ideo08, cformat(%4.2f) 
svy: regress pid12 moralissues08 pid08 orthodox08 relcom08 age female black college ideo08, cformat(%4.2f) 
svy: logit orthodox12 moralissues08 pid08 orthodox08 relcom08 age female black college ideo08, cformat(%4.2f) 
svy: regress relcom12 moralissues08 pid08 orthodox08 relcom08 age female black college ideo08, cformat(%4.2f) 


/// ===========================================================
/// = TABLE O ROBUSTNESS CHECK: AUTHORITARIANISM ON ALL 4 DVS =  
/// ===========================================================
/// use the 2 child rearing items: ranking of obey and think for ones self
fre obey_1
gen obey08=obey_1
recode obey08 1=1 2=.75 3=.5 4=.25 5=0
label variable obey08 "rank importance child obey"
label define import 0 "least imp" 1 "most imp"
label value obey08 import
fre obey08

fre thnkself_1
gen thnkself08=thnkself_1
recode thnkself08 1=1 2=.75 3=.5 4=.25 5=0
label variable thnkself08 "think for oneself"
label value thnkself08 import
fre thnkself08

gen auth08=(obey08-thnkself08+1)/2
label variable auth08 "authorianism"
label define auth 0 "non-auth" 1 "auth"
label value auth08 auth
fre auth08

svy: regress moralissues12 moralissues08 pid08 orthodox08 relcom08 age female black college auth08, cformat(%4.2f)
svy: regress pid12 moralissues08 pid08 orthodox08 relcom08 age female black college auth08, cformat(%4.2f)
svy: logit orthodox12 moralissues08 pid08 orthodox08 relcom08 age female black college auth08, cformat(%4.2f)
svy: regress relcom12 moralissues08 pid08 orthodox08 relcom08 age female black college auth08, cformat(%4.2f)


/// =======================================================
/// = TABLE P ROBUSTNESS CHECK: BASIC VALUES ON ALL 4 DVS =  
/// =======================================================
/// Schwartz openness
fre valdiff_3
gen stim1=valdiff_3
replace stim1=6-stim1
label variable stim1 "do diff things imp"
label define imp 0 "not like me at all" 5 "very much like me"
label value stim1 imp
fre stim1

fre valfree_3
gen stim2=valfree_3
replace stim2=6-stim2
label variable stim1 "taking risk imp"
label value stim2 imp
fre stim2

fre valorig_3
gen self1=valorig_3
replace self1=6-self1
label variable self1 "do things orig ways imp"
label value self1 imp
fre self1

fre valfree_3
gen self2=valfree_3
replace self2=6-self2
label variable self2 "be free indp imp"
label value self2 imp
fre self2

alpha stim1-self2, item std
egen valmiss=rowmiss(stim1 stim2 self1 self2)
egen open=rowmean(stim1 stim2 self1 self2) if valmiss<2
replace open=open/5
label variable open "Schwartz open to exp"
label value open imp 
fre open

/// Schwartz conservation
fre valsafe_3
gen sec1=valsafe_3
replace sec1=6-sec1
label variable sec1 "safety imp"
label value sec1 imp
fre sec1

fre valdfnd_3
gen sec2=valdfnd_3
replace sec2=6-sec2
label variable sec2 "govt def citizens imp"
label value sec2 imp
fre sec2

fre valrule_3
gen conform1=valrule_3
replace conform1=6-conform1
label variable conform1 "rules are imp"
label value conform1 imp
fre conform1

fre valprpr_3
gen conform2=valprpr_3
replace conform2=6-conform2
label variable conform2 "do things prop imp"
label value conform2 imp
fre conform2

fre valmod_3
gen trad1=valmod_3
replace trad1=6-trad1
label variable trad1 "be modest imp"
label value trad1 imp
fre trad1

fre valtrdn_3
gen trad2=valtrdn_3
replace trad2=6-trad2
label variable trad2 "trad imp"
label value trad2 imp
fre trad2

alpha sec1-trad2, item std
egen valmiss2=rowmiss(sec1 sec2 conform1 conform2 trad1 trad2)
egen conservation=rowmean(sec1 sec2 conform1 conform2 trad1 trad2) if valmiss2<3
replace conservation=conservation/5
label variable conservation "Schwartz conservation"
label value conservation imp 
fre conservation

svy: regress moralissues12 moralissues08 pid08 orthodox08 relcom08 age female black college open conservation, cformat(%4.2f)
svy: regress pid12 moralissues08 pid08 orthodox08 relcom08 age female black college open conservation, cformat(%4.2f)
svy: logit orthodox12 moralissues08 pid08 orthodox08 relcom08 age female black college open conservation, cformat(%4.2f)
svy: regress relcom12 moralissues08 pid08 orthodox08 relcom08 age female black college open conservation, cformat(%4.2f)


/// ===========================================
/// = TABLE R ROBUSTNESS CHECK: INTERACTIONS  =  
/// ===========================================
/// age
gen moral_age=moralissues08*age

svy: regress pid12 moralissues08 pid08 orthodox08 relcom08 age female black college moral_age, cformat(%4.2f) 
svy: logit orthodox12 moralissues08 pid08 orthodox08 relcom08 age female black college moral_age, cformat(%4.2f) 
svy: regress relcom12 moralissues08 pid08 orthodox08 relcom08 age female black college moral_age, cformat(%4.2f) 

/// pid
gen moral_pid=moralissues08*pid08
svy: regress pid12 moralissues08 pid08 orthodox08 relcom08 age female black college moral_pid, cformat(%4.2f) 
svy: logit orthodox12 moralissues08 pid08 orthodox08 relcom08 age female black college moral_pid, cformat(%4.2f) 
svy: regress relcom12 moralissues08 pid08 orthodox08 relcom08 age female black college moral_pid, cformat(%4.2f) 

/// education
svy: regress pid12 moralissues08 pid08 orthodox08 relcom08 age female black  ///
  i.college i.college#c.moralissues08   
  
svy: logit orthodox12 moralissues08 pid08 orthodox08 relcom08 age female black  ///
  i.college i.college#c.moralissues08  

svy: regress relcom12 moralissues08 pid08 orthodox08 relcom08 age female black  ///
  i.college i.college#c.moralissues08 

  
/// ============================================
/// = TABLE W ROBUSTNESS CHECK: EIV REGRESSION =  
/// ============================================
/// we use ordinal alpha reliability estimates for ordinal level indicators 
/// these estimates are constrained so that stability point estimate <= .90
/// otherwise, EIV results can suggest lagged variables are perfectly stable
/// doesn't square with evidence of substantial macro-level liberalization in periods too short to be accounted for by cohort replacement
/// addresses criticisms raised by Converse, Luskin, Zaller about measurement (over)adjustments that artifactually enahnce stability
/// pid estimates comes from Chen and Goren (2016) estimates in PRQ paper (3-wave Wiley-Wiley models)
/// use OLS for dichotomous orthodox measure
eivreg moralissues12 moralissues08 pid08 orthodox08 relcom08 age female black college, reliab(pid08 .884 moralissues08 .96 relcom08 .834) cformat(%4.2f) 
eivreg pid12 moralissues08 pid08 orthodox08 relcom08 age female black college, reliab(pid08 .884 moralissues08 .96 relcom08 .834) cformat(%4.2f)
eivreg orthodox12 moralissues08 pid08 orthodox08 relcom08 age female black college, reliab(pid08 .884 moralissues08 .96 relcom08 .834) cformat(%4.2f)
eivreg relcom12 moralissues08 pid08 orthodox08 relcom08 age female black college, reliab(pid08 .884 moralissues08 .96 relcom08 .92) cformat(%4.2f)


/// =============================================
/// = TABLE AA: ROBUSTNESS CHECK: IV REGRESSION =  
/// =============================================
/// we use 2SLS for moral issues, pid, and relcom models
/// we use ivprobit for orthodox model

/// 2SLS: pid 
svy: ivregress 2sls moralissues12 moralissues08 orthodox08 relcom08 age female black college (pid12 = pid08), cformat(%4.2f) 
svy: ivregress 2sls pid12 pid08  orthodox08 relcom08 age female black college (moralissues12= moralissues08), cformat(%4.2f) 

/// 2SLS: orthodox
svy: ivregress 2sls moralissues12 pid08 moralissues08 relcom08 age female black college (orthodox12 = orthodox08), cformat(%4.2f) 
svy: ivprobit orthodox12 pid08 orthodox08 relcom08 age female black college (moralissues12 = moralissues08), cformat(%4.2f) 

/// 2SLS: relcom
svy: ivregress 2sls moralissues12 pid08 moralissues08 orthodox08 age female black college (relcom12 = relcom08), cformat(%4.2f) 
svy: ivregress 2sls relcom12 pid08 orthodox08 relcom08 age female black college (moralissues12 = moralissues08), cformat(%4.2f) 


// =============================================================
/// = TABLE DD & FF: SELECTION AND ENDOGENOUS TREATMENT MODELS =  
/// =============================================================
/// recode moralissues into binary treatment variable
/// first recode drops scale midpoint moderates
/// second recode drops .40-.60 scale moderates
/// then code variables used to predict treatment assignment
/// then recode orthodox into 3 point scale to better approximate normality assumption for method
tab moralissues08
clonevar treat08=moralissues08
recode treat08 0/.499=0 .500011/1=1 .4999/.5=.
label define treat 0 "untreated=prog" 1 "treated=trad" 
label value treat08 treat
fre treat08

tab moralissues08
clonevar treat08r=moralissues08
recode treat08r 0/.3999=0 .600001/1=1 .4/.6=.
label value treat08r treat
fre treat08r

fre marital_1
clonevar married=marital_1
recode married 1=1 2/5=0
label define married 0 "other" 1 "married" 
label value married married
fre married

fre babies_1 preteen_1 teens_1
gen numkids=babies_1+preteen_1+teens_1
fre numkids

fre region_1
gen south=region_1
recode south 1/4=0 5/7=1 8/9=0
label define south 0 "other" 1 "south" 
label value south south
fre south

fre reg16_1
gen south16=reg16_1
recode south16 1/4=0 5/7=1 8/9=0
label value south16 south
fre south16

fre relig16_1
gen secular16=relig16_1
recode secular16 1/3=0 4=1 5/13=0
label define sec 0 "rel id" 1 "none" 
label value secular16 sec
fre secular16


fre bible_1 
gen orthodox08c=bible_1 
recode orthodox08c 1=1 2=.5 3=0 4=. .d=.d .n=.n 
label variable orthodox08c "Bible literal"
label value orthodox08c orthodox
fre orthodox08c

fre bible_3 
gen orthodox12c=bible_3 
recode orthodox12c 1=1 2=.5 3=0 4=. 
label variable orthodox12c "Bible literal"
label value orthodox12c orthodox
fre orthodox12c


/// first do probit model to assess fit of treatment assignment equation
svy: probit treat08 age college married numkids childs_1 south south16 secular16, cformat(%4.2f)
probit treat08 age college married numkids childs_1 south south16 secular16 [pw=wt123], cformat(%4.2f)
fitstat
estimates store selection1

svy: probit treat08r age college married numkids childs_1 south south16 secular16, cformat(%4.2f)
probit treat08r age college married numkids childs_1 south south16 secular16, cformat(%4.2f)
fitstat
estimates store selection2

esttab selection1 selection2, b(%6.2f) t ar2 ///
  title(Treatment Selection Model ) ///
  nonumbers mtitles("Measure 1" "Measure 2") ///
  addnote("Source: 2008-12 GSS") 


/// pid
etregress pid12 pid08 age female black college [pweight = wt123], /// 
  treat(treat08 = age college married numkids childs_1 south south16 secular16) cformat(%4.2f)
estimates store model1

etregress pid12 pid08 age female black college [pweight = wt123], /// 
  treat(treat08r = age college married numkids childs_1 south south16 secular16) cformat(%4.2f)
estimates store model2

/// orthodox
etregress orthodox12c orthodox08c age female black college [pweight = wt123], /// 
  treat(treat08 = age college married numkids childs_1 south south16 secular16) cformat(%4.2f)
estimates store model3

etregress orthodox12c orthodox08c age female black college [pweight = wt123], /// 
  treat(treat08r = age college married numkids childs_1 south south16 secular16) cformat(%4.2f)
estimates store model4

/// relcom
etregress relcom12 relcom08 age female black college [pweight = wt123], /// 
  treat(treat08 = age college married numkids childs_1 south south16 secular16) cformat(%4.2f)
estimates store model5

etregress relcom12 relcom08 age female black college [pweight = wt123], /// 
  treat(treat08r = age college married numkids childs_1 south south16 secular16 ) cformat(%4.2f)
estimates store model6


/// summarize in table
esttab model1 model2 model3 model4 model5 model6, b(%6.2f) se ar2 ///
  title(Endogenous Treatment models: Moral Issues ATE on . . . ) ///
  nonumbers mtitles("PID: T1" "PID: T2" "Bible: T1" "Bible: T2" "Rel: T1" "Rel: T2") ///
  addnote("Source: 2008-12 GSS") 
